<template>
  <!-- <a class="el-icon-document-copy copyImg" :data-clipboard-text="text" @click="onCopy" ></a> -->
  <el-icon class="copyImg" :data-clipboard-text="text" @click="onCopy"><CopyDocument /></el-icon>
</template>

<script>
import Clipboard from "clipboard";
export default {
  props:{
    text:{
      type: String,
      required: true
    }
  },
  methods:{
    onCopy(val) {
      var clipboard = new Clipboard(".copyImg");
      clipboard.on("success", e => {
        this.$message.success('复制成功')
        // 释放内存
        clipboard.destroy();
      });
    },
  },
}
</script>

<style scoped lang="scss">
.copyImg {
  font-size: 15px;
  color: var(--el-color-primary);
  margin-right: 5px;
  cursor: pointer;
  position: relative;
  top: 1px;
  &:hover {
    color: #79bbff;
    transition: .3s all;
  }
}
</style>
